<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
			
			
			List<EquipmentDetails> list1 =(List<EquipmentDetails>)session.getAttribute("hehe");
%>

<script type="text/javascript">
	function Confirm(id) {
		var text = confirm("Are you sure ?");

		if (text == true) {
			//alert("Okey, Deleted !!!");
			location.href = "./servlet/Control_EquipmentDetail?delete=" + id;
		} else {
			alert("What ever !!!");
		}
	}
	
</script> 

<link rel="stylesheet" href="css/menu.css" type="text/css"/>
<link rel="stylesheet" href="css/CommonCSS.css" type="text/css"/>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page import="iwpl.project.dao.*"%>
<%@page import="iwpl.project.entities.*"%>
<%@page import="iwpl.project.servlet.*"%>
<%@page import="iwpl.project.interfaces.*"%>
<%@page import="iwpl.project.entitymanagerhelper.*"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'Manage_EquipmentDetails.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	

  </head>
  
  <body> 
      
   
  <table width="450" border="0" align="center"> 
<tbody><tr> 
<td>
	<form id="form1" runat="server"  action="./servlet/Control_EquipmentDetail"  method="post" >
<br></td> 
<td>
Apartment Number: 
<select name="cboApartmentNumber" style="width: 150px";>
			<option></option>	
				<% 
				ApartmentsDAO objDao= new ApartmentsDAO();
				List<Apartments> lstOff = objDao.findAll();
					for( Iterator it = lstOff.iterator(); it.hasNext(); ) {
						Apartments apart = (Apartments)it.next();
						%> 		
						 										 	
						<option value="<%=apart.getId()%>" label="<%=apart.getApartmentNumber()%>">
																	
						</option>
						<%} %>
</select>

</td> 
<td>
Equipment Name: 
<select name="cboEquipmentName" style="width: 150px";>
			<option></option>	
				<% 
				EquipmentsDAO objDao1= new EquipmentsDAO();
				List<Equipments> lstOff1 = objDao1.findAll();
					for( Iterator it = lstOff1.iterator(); it.hasNext(); ) {
						Equipments equip = (Equipments)it.next();
						%> 		
						 										 	
						<option value="<%=equip.getId()%>" label="<%=equip.getEquipmentName()%>">
																	
						</option>
						<%} %>
</select>
</td><td valign="bottom"><strong><input type="submit" value="Search" name="btnSearch"></strong> <br></td></tr>
</tbody></table> 
    <table height="66" width="450" border="0" align="center"> 
<tbody><tr> 
<td align="center" style="background-color: rgb(66, 171, 221);"><strong>&nbsp;STT<br></strong></td>
<td align="center" style="background-color: rgb(66, 171, 221);"><strong>&nbsp;ID<br></strong></td>
<td align="center" style="background-color: rgb(66, 171, 221);"><strong>&nbsp;Number Apartment<br></strong></td> 
<td align="center" style="background-color: rgb(66, 171, 221);"><strong>Equipment Name<br></strong> </td>
<td align="center" style="background-color: rgb(66, 171, 221);"><strong>Update<br></strong></td>
<td align="center" style="background-color: rgb(66, 171, 221);"><strong>Delete<br></strong></td></tr> 

	
</tr> 
	<%
	
													EquipmentDetailsDAO dao = new EquipmentDetailsDAO();
													
													List<EquipmentDetails> list=list1;
													//List<EquipmentDetails> list = dao.findAll();
													if(list!=null)
													{
													int i = 0;
														
													for (Iterator<EquipmentDetails> it = list.iterator(); it.hasNext();) {
														EquipmentDetails equipd = (EquipmentDetails) it.next();
														i++;

														if (i % 2 != 0) {
															out.println("<tr bgcolor=\"#CCFFFF\"><td align = center>");
														} else {
															out.println("<tr bgcolor=\"#99CCCC\"><td align = center>");
														}
														out.println(i + "</td>");
														out.println("<td align = center>" + equipd.getId() + "</td>");
														out.println("<td align = center>" + equipd.getApartments().getApartmentNumber()+ "</td>");
														out.println("<td align = center>" + equipd.getEquipments().getEquipmentName()+ "</td>");
														out.println("<td align = center><a href="
																+ "/DepartmentManage/Update_EquipmentDetails.jsp?id="
																+ equipd.getId().toString() + " /><img src="
																+ "./images/Edit.jpg" + " /></td>");
														
														out.println("<td align = center><a href=javascript:Confirm('" + equipd.getId()
																+ "') /><img src=" + "./images/Delete.jpg"
																+ " /></td></tr>");
														

													}
													//list1.clear();															
														//list.clear();
													}
													else													
													{
																									
													list = dao.findAll();
													}
												%> 
												
	</from>
</tbody></table> 
<div>
<input align="center" type="button" value="Insert" name="btInsert" onclick="self.location='Insert_EquipmentDetails.jsp'"></a></div>  

  </body>
</html>
